package com.ruoyi.back.controller

import com.ruoyi.app.common.Data
import com.ruoyi.app.common.PageData
import com.ruoyi.app.common.pageInfo
import com.ruoyi.back.domain.SpreadCenter
import com.ruoyi.back.domain.dto.SpreadCenterListSearchDto
import com.ruoyi.back.service.SpreadCenterService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiImplicitParam
import io.swagger.annotations.ApiImplicitParams
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("system/spreadCenter")
@Api(tags = ["个人中心-推广中心"])
class SpreadCenterController {

    @Autowired
    private lateinit var spreadCenterService: SpreadCenterService


    @ApiOperation("保存推广中心")
    @PostMapping("save")
    fun saveSpreadCenter(@RequestBody spreadCenter: SpreadCenter): Data<Boolean> = spreadCenterService.saveSpreadCenter(spreadCenter)

    @ApiOperation("推广中心分页")
    @GetMapping("list")
    fun spreadCenterPage(spreadCenterListSearchDto: SpreadCenterListSearchDto): PageData<SpreadCenter> = spreadCenterService.spreadCenterPage(spreadCenterListSearchDto).pageInfo()

    @ApiOperation("移除推广中心")
    @ApiImplicitParams(
        ApiImplicitParam(name = "spreadCenterIds", value = "推广中心id 多个用逗号拼接", type = "path", required = true)
    )
    @GetMapping("remove/{spreadCenterIds}")
    fun removeSpreadCenter(@PathVariable spreadCenterIds: String): Data<Boolean> = spreadCenterService.removeSpreadCenter(spreadCenterIds)
}